"""
1.写一个脚本
2.脚本中实现一个自动将图片从本地路径上传到服务器的功能
"""

import os
import requests

# Specify the local path of the image file
image_path = "/path/to/image.jpg"

# Specify the URL of the server endpoint to upload the image
upload_url = "http://example.com/upload"

# Open the image file in binary mode
with open(image_path, "rb") as file:
    # Read the contents of the image file
    image_data = file.read()

# Send a POST request to the server with the image data
response = requests.post(upload_url, data=image_data)

# Check if the request was successful
if response.status_code == 200:
    print("Image uploaded successfully")
else:
    print("Failed to upload image")